package com.tanhua.dobbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dobbo.mappers.UserMapper;
import com.tanhua.dubbo.api.UserApi;
import com.tanhua.model.dimain.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 杰哥不要啦~
 * @date 2021/10/22
 */
@DubboService
public class UserApiImpl implements UserApi {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByMobile(String mobile) {
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.eq("mobile",mobile);
        return userMapper.selectOne(qw);
    }

    @Override
    public long save(User user) {
        userMapper.insert(user);
        return user.getId();
    }

    @Override
    public void update(User user) {
        userMapper.updateById(user);
    }

    @Override
    public User findById(Long userid) {
        return userMapper.selectById(userid);
    }

    @Override
    public User findByhuanxin(String huanxinid) {
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.eq("hx_user",huanxinid);
        return userMapper.selectOne(qw);
    }
    //根据环信id查用户信息

}
